
package com.tencent.weibo.api
{
	import com.tencent.weibo.log.LevelLogger;
	import com.tencent.weibo.operation.IRequestOperation;
	import com.tencent.weibo.operation.URLRequestOperation;
	
	import flash.events.IEventDispatcher;
	
	import mx.logging.ILogger;
	
	/**
	 * 名单相关的API
	 * @langversion 3.0
	 * @playerversion Flash 9
	 * @playerversion AIR 1.1
	 *
	 */
	public class List extends AbstractAPI
	{
		/**
		 * 日志输出对象
		 */
		public static var logger:ILogger=LevelLogger.getLogger("com.tencent.weibo.api.List");
		
		/**
		 * 1.名单订阅成员列表信息
		 * @param listid 名单id
		 * @param page 第几页
		 * @return IRequestOperation实例
		 */		
		public function listFollowers(listid:String,page:int=0):IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"list/list_followers";
			var attachParms:Object = {};
			attachParms.listid = listid;
			attachParms.page = page;
			return generateDataRequest(url,attachParms,"POST");
		}
		/**
		 * 2.我订阅的名单信息
		 * @param pageflag 第几页
		 * @return IRequestOperation实例
		 */		
		public function myFollowList(pageflag:int=0):IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"list/myfollowlist";
			var attachParms:Object = {};
			attachParms.pageflag = pageflag;
			return generateDataRequest(url,attachParms,"POST");
		}
		/**
		 * 3.创建名单
		 * @param name 名单的名称（128字节，仅支持中文、字母、数字、下划线或减号）
		 * @param description 名单的描述（420字节）
		 * @param tag 名单的标签，每个标签8个字以内，以空格间隔，最多填写10个 （256字节，仅支持中文、字母、数字）
		 * @param access 浏览权限 0:所有人可见  1:只有我自己可见
		 * @return IRequestOperation实例
		 */		
		public function create(name:String,description:String,tag:String,access:int=0):IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"list/create";
			var attachParms:Object = {};
			attachParms.name = name;
			attachParms.description = description;
			attachParms.tag = tag;
			attachParms.access = access;
			return generateDataRequest(url,attachParms,"POST");
		}
		/**
		 * 4.删除名单
		 * @param listid 名单的id
		 * @return IRequestOperation实例
		 */		
		public function deleteList(listid:String):IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"list/delete";
			var attachParms:Object = {};
			attachParms.listid = listid;
			return generateDataRequest(url,attachParms,"POST");
		}
		/**
		 * 5.修改名单
		 * @param listid 名单id
		 * @param name 名单的名称（128字节，仅支持中文、字母、数字、下划线或减号）
		 * @param description 名单的描述（420字节）
		 * @param tag 名单的标签，每个标签8个字以内，以空格间隔，最多填写10个 （256字节，仅支持中文、字母、数字）
		 * @param access 浏览权限 0:所有人可见  1:只有我自己可见
		 * @return IRequestOperation实例
		 */		
		public function edit(listid:String,name:String,description:String,tag:String,access:int=0):IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"list/edit";
			var attachParms:Object = {};
			attachParms.listid = listid;
			attachParms.name = name;
			attachParms.description = description;
			attachParms.tag = tag;
			attachParms.access = access;
			return generateDataRequest(url,attachParms,"POST");
		}
		/**
		 * 6.查询我创建的名单
		 * @return IRequestOperation实例
		 */		
		public function getList():IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"list/get_list";
			var attachParms:Object = {};
			return generateDataRequest(url,attachParms,"POST");
		}
		/**
		 * 7.筛选指定的用户是否在名单中
		 * @param listids 名单列表，以逗号“,”分隔，如123,456（最多30个）
		 * @param name 用户帐号（可选）
		 * @param fopenid 用户的openid（可选）,name和fopenid至少选一个，若同时存在则以name值为主
		 * @return IRequestOperation实例
		 */		
		public function checkUserInList(listids:String,name:String=null,fopenid:String=null):IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"list/check_user_in_list";
			var attachParms:Object = {};
			attachParms.listids = listids;
			if(name != null)
				attachParms.name = name;
			if(fopenid != null)
				attachParms.fopenid = fopenid;
			return generateDataRequest(url,attachParms,"POST");
		}
		/**
		 * 8.名单属性信息
		 * @param listids 名单列表，以逗号“,”分隔，如123,456（最多不超过10个）
		 * @return IRequestOperation实例
		 */		
		public function listAttr(listids:String):IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"list/list_attr";
			var attachParms:Object = {};
			attachParms.listids = listids;
			return generateDataRequest(url,attachParms,"POST");
		}
		/**
		 * 9.订阅多个名单
		 * @param listids 名单列表，以逗号“,”分隔，如123,456（最多不超过30个）
		 * @return IRequestOperation实例
		 */		
		public function follow(listids:String):IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"list/follow";
			var attachParms:Object = {};
			attachParms.listids = listids;
			return generateDataRequest(url,attachParms,"POST");
		}
		/**
		 * 10.取消订阅多个名单
		 * @param listids 名单列表，以逗号“,”分隔，如123,456（最多不超过30个）
		 * @return IRequestOperation实例
		 */		
		public function undoFollow(listids:String):IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"list/undo_follow";
			var attachParms:Object = {};
			attachParms.listids = listids;
			return generateDataRequest(url,attachParms,"POST");
		}
		/**
		 * 11.收录指定用户到名单
		 * @param names 用户账号列表，以“,”分隔，如aaa,bbb（最多不超过30个）
		 * @param listid 名单id
		 * @return IRequestOperation实例
		 */		
		public function addToList(names:String,listid:String):IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"list/add_to_list";
			var attachParms:Object = {};
			attachParms.names = names;
			attachParms.listid = listid;
			return generateDataRequest(url,attachParms,"POST");
		}
		/**
		 * 12.从名单中删除指定用户
		 * @param names 用户账号列表，以“,”分隔，如aaa,bbb（最多不超过30个）
		 * @param listid 名单id
		 * @return IRequestOperation实例
		 */		
		public function delFromList(names:String,listid:String):IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"list/del_from_list";
			var attachParms:Object = {};
			attachParms.names = names;
			attachParms.listid = listid;
			return generateDataRequest(url,attachParms,"POST");
		}
		/**
		 * 13.查询指定用户所在的所有list
		 * @param name 用户帐号
		 * @return IRequestOperation实例
		 */		
		public function getOtherInList(name:String):IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"list/get_other_in_list";
			var attachParms:Object = {};
			attachParms.name = name;
			return generateDataRequest(url,attachParms,"POST");
		}
		/**
		 * 14.查询名单成员列表
		 * @param listid 名单id
		 * @param pageflag 第几页(0是第一页，每页有15个）
		 * @return IRequestOperation实例
		 */		
		public function listUsers(listid:String,pageflag:int=0):IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"list/listusers";
			var attachParms:Object = {};
			attachParms.listid = listid;
			attachParms.pageflag = pageflag;
			return generateDataRequest(url,attachParms,"POST");
		}
		/**
		 * 15.查询指定微博用户的名单相关信息
		 * @param names 用户账号列表，以“,”分隔，如aaa,bbb（最多不超过30个）
		 * @return IRequestOperation实例
		 */		
		public function listInfo(names:String):IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"list/list_info";
			var attachParms:Object = {};
			attachParms.names = names;
			return generateDataRequest(url,attachParms,"POST");
		}
		
	}
}